//
// Created by zhengbo on 23-4-18.
//

#include <GL/gl.h>
#include "ObjectDetection.h"

std::vector<Vector3f> BBox::GetCorners() const {
    std::vector<Vector3f> corners(8);
    Vector3f minPoint = centerPoint - boxSize / 2.0;
    Vector3f maxPoint = centerPoint + boxSize / 2.0;
    corners[0] = Vector3f(minPoint.x(), minPoint.y(), minPoint.z());
    corners[1] = Vector3f(minPoint.x(), minPoint.y(), maxPoint.z());
    corners[2] = Vector3f(minPoint.x(), maxPoint.y(), minPoint.z());
    corners[3] = Vector3f(minPoint.x(), maxPoint.y(), maxPoint.z());
    corners[4] = Vector3f(maxPoint.x(), minPoint.y(), minPoint.z());
    corners[5] = Vector3f(maxPoint.x(), minPoint.y(), maxPoint.z());
    corners[6] = Vector3f(maxPoint.x(), maxPoint.y(), minPoint.z());
    corners[7] = Vector3f(maxPoint.x(), maxPoint.y(), maxPoint.z());
    return corners;
}

std::vector<std::pair<Vector3f, Vector3f>> BBox::GetEdges() const {
    auto cornerPoints = GetCorners();
    return {
            {cornerPoints[0], cornerPoints[1]},
            {cornerPoints[0], cornerPoints[2]},
            {cornerPoints[0], cornerPoints[4]},
            {cornerPoints[1], cornerPoints[3]},
            {cornerPoints[1], cornerPoints[5]},
            {cornerPoints[2], cornerPoints[3]},
            {cornerPoints[2], cornerPoints[6]},
            {cornerPoints[3], cornerPoints[7]},
            {cornerPoints[4], cornerPoints[5]},
            {cornerPoints[4], cornerPoints[6]},
            {cornerPoints[5], cornerPoints[7]},
            {cornerPoints[6], cornerPoints[7]}
    };
}


